Disable LTO for host (plugin, build script) builds
authorMikko Perttunen <cyndis@kapsi.fi>
Sun, 1 Mar 2015 22:53:46 +0000 (00:53 +0200)
committerMikko Perttunen <cyndis@kapsi.fi>
Mon, 2 Mar 2015 17:14:50 +0000 (19:14 +0200)
When building host code, -C prefer-dynamic is passed, but that option
is mutually exclusive with -C lto. Thus when LTO is specified, rustc
errors out.

src/cargo/ops/cargo_rustc/mod.rs

index 3608429abd100bf4c638e18a5d0d6ed5837b8d89..569fa6781ccc0585240c1642bae717ff31aa16fd 100644 (file)
@@ -587,7 +587,12 @@ fn build_base_args(cx: &Context,
     if profile.opt_level() != 0 {
         cmd.arg("-C").arg(&format!("opt-level={}", profile.opt_level()));
     }
-    if (target.is_bin() || target.is_staticlib()) && profile.lto() {
+
+    // Disable LTO for host builds as prefer_dynamic and it are mutually
+    // exclusive.
+    let lto = (target.is_bin() || target.is_staticlib()) && profile.lto() &&
+              !profile.is_for_host();
+    if lto {
         cmd.args(&["-C", "lto"]);
     } else {
         // There are some restrictions with LTO and codegen-units, so we